﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace _02_Client
{
    class Program
    {
        static void Main(string[] args)
        {
            UdpClient client = new UdpClient();
            Thread.Sleep(5000);
            //client.Connect(new IPEndPoint(IPAddress.Parse("10.7.5.1"), 12345));

            IPEndPoint point = null;
            while(true)
            {
                Console.Write("Enter message: ");
                string message = Console.ReadLine();
                client.Send(Encoding.ASCII.GetBytes(message), Encoding.ASCII.GetByteCount(message),new IPEndPoint(IPAddress.Broadcast, 12345));
               // client.Send(Encoding.ASCII.GetBytes(message), Encoding.ASCII.GetByteCount(message));
                byte[] buffer = client.Receive(ref point);
                Console.WriteLine("{0} : {1}", point.Address, Encoding.ASCII.GetString(buffer));
            }
        }
    }
}
